home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / awe2-0_1.lha / awe2-0.1 / Src / RCS / Barrier.cc,v < prev    next >
Text File  |  1989-05-04  |  3KB  |  204 lines

  1. head     3.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    grunwald:3.2; strict;
  6. comment  @@;
  7.  
  8.  
  9. 3.2
  10. date     89.02.20.15.32.04;  author grunwald;  state Exp;
  11. branches ;
  12. next     3.1;
  13.  
  14. 3.1
  15. date     88.12.20.13.48.31;  author grunwald;  state Exp;
  16. branches ;
  17. next     1.3;
  18.  
  19. 1.3
  20. date     88.10.30.13.04.20;  author grunwald;  state Exp;
  21. branches ;
  22. next     1.2;
  23.  
  24. 1.2
  25. date     88.09.28.22.13.17;  author grunwald;  state Exp;
  26. branches ;
  27. next     1.1;
  28.  
  29. 1.1
  30. date     88.09.18.16.42.18;  author grunwald;  state Exp;
  31. branches ;
  32. next     ;
  33.  
  34.  
  35. desc
  36. @@
  37.  
  38.  
  39. 3.2
  40. log
  41. @Start using Gnu library heaps for schedulers
  42. @
  43. text
  44. @// This may look like C code, but it is really -*- C++ -*-
  45. // 
  46. // Copyright (C) 1988 University of Illinois, Urbana, Illinois
  47. //
  48. // written by Dirk Grunwald (grunwald@@cs.uiuc.edu)
  49. //
  50. #include "Barrier.h"
  51. #include "CpuMultiplexor.h"
  52. #include "Thread.h"
  53.  
  54. Barrier::~Barrier()
  55. {
  56. }
  57.  
  58. void
  59. Barrier::releaseAll()
  60. {
  61.     while ( ! pPileOfThreads.isEmpty() ) {
  62.     Thread *p = (Thread *) (pPileOfThreads.remove());
  63.     if (debugFlag) {
  64.         cerr << "Release " << *p << "\n";
  65.     }
  66.     ThisCpu -> add(p);
  67.     }
  68. }
  69.  
  70. //
  71. //    Make everyone exit
  72. //
  73. void
  74. Barrier::lowerBarrier()
  75. {
  76.     lock.reserve();
  77.     generation++;
  78.     pCount = 0;
  79.     releaseAll();
  80.     lock.release();
  81. }
  82.  
  83. void
  84. Barrier::rendezvous()
  85. {
  86.     lock.reserve();
  87.     if ( pCount == pHeight-1) {
  88.     pCount = 0;
  89.     generation++;
  90.     releaseAll();
  91.     lock.release();
  92.     } else {
  93.     int gen = generation;
  94.     pCount++;
  95.     lock.release();
  96.     for (int i = 0; i < pLoops; i++) {
  97.         if (gen != generation) break;
  98.     }
  99.     if (gen == generation) {
  100.         ThisCpu -> reserveByException( this );
  101.     }
  102.     }
  103. }
  104.  
  105. bool
  106. Barrier::reserveByException(Thread *byWho)
  107. {
  108.     int blocked = 0;
  109.  
  110.     lock.reserve();
  111.     if ( pCount == pHeight) {
  112.     pCount = 0;
  113.     generation++;
  114.     releaseAll();
  115.     } else {
  116.     pPileOfThreads.add( byWho );
  117.     blocked = 1;
  118.     }
  119.     lock.release();
  120.  
  121.     return( blocked );
  122. }
  123.  
  124. void
  125. Barrier::height(int newHeight)
  126. {
  127.     lock.reserve();
  128.     if (pCount >= newHeight) {
  129.     pCount = 0;
  130.     generation++;
  131.     releaseAll();
  132.     }
  133.     else {
  134.     pHeight = newHeight;
  135.     }
  136.     lock.release();
  137. }
  138. @
  139.  
  140.  
  141. 3.1
  142. log
  143. @Steay version
  144. @
  145. text
  146. @@
  147.  
  148.  
  149. 1.3
  150. log
  151. @*** empty log message ***
  152. @
  153. text
  154. @d27 3
  155. d31 10
  156. d44 2
  157. a45 2
  158.     if ( count == pHeight-1) {
  159.     count = 0;
  160. d51 1
  161. a51 1
  162.     count++;
  163. d68 2
  164. a69 2
  165.     if ( count == pHeight) {
  166.     count = 0;
  167. d79 15
  168. @
  169.  
  170.  
  171. 1.2
  172. log
  173. @*** empty log message ***
  174. @
  175. text
  176. @d1 6
  177. d8 1
  178. a8 1
  179. #include "HardwareCpu.h"
  180. d23 1
  181. a23 1
  182.     ThisCpu -> add(p,0);
  183. d38 1
  184. a54 1
  185.     count++;
  186. @
  187.  
  188.  
  189. 1.1
  190. log
  191. @Initial revision
  192. @
  193. text
  194. @d12 1
  195. a12 1
  196.     while ( pPileOfThreads.isEmpty() ) {
  197. d27 1
  198. d31 1
  199. d33 6
  200. a38 1
  201.     ThisCpu -> reserveByException( this );
  202. d51 1
  203. @
  204.